package com.uduemc.biso.module.basic.service.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.github.pagehelper.page.PageMethod;
import com.uduemc.biso.core.extities.center.SysHostType;
import com.uduemc.biso.module.basic.service.mapper.SysHostTypeMapper;
import com.uduemc.biso.module.basic.service.service.SysHostTypeService;

@Service
public class SysHostTypeServiceImpl implements SysHostTypeService {

	@Autowired
	private SysHostTypeMapper sysHostTypeMapper;

	@Override
	public SysHostType insert(SysHostType sysHostType) {
		sysHostTypeMapper.insertSelective(sysHostType);
		return findOne(sysHostType.getId());
	}

	@Override
	public SysHostType updateById(SysHostType sysHostType) {
		sysHostTypeMapper.updateByPrimaryKeySelective(sysHostType);
		return findOne(sysHostType.getId());
	}

	@Override
	public SysHostType findOne(Long id) {
		return sysHostTypeMapper.selectByPrimaryKey(id.longValue());
	}

	@Override
	public List<SysHostType> findAll(Pageable pageable) {
		int pageNumber = pageable.getPageNumber();
		int pageSize = pageable.getPageSize();
		PageMethod.startPage(pageNumber, pageSize);
		return sysHostTypeMapper.selectAll();
	}

	@Override
	public void deleteById(Long id) {
		sysHostTypeMapper.deleteByPrimaryKey(id.longValue());
	}

	@Override
	public List<SysHostType> findAll() {
		return sysHostTypeMapper.selectAll();
	}

}
